package com.supcalls;

import cn.hutool.core.collection.CollUtil;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

public class CollUtilExample {
    public static void main(String[] args) {
        // 创建 List 和 Set
        List<String> list1 = new ArrayList<>();
        list1.add("apple");
        list1.add("banana");
        list1.add("cherry");

        List<String> list2 = new ArrayList<>();
        list2.add("banana");
        list2.add("cherry");
        list2.add("date");

        // 合并两个集合
        List<String> mergedList = (List<String>) CollUtil.union(list1, list2);
        System.out.println("Merged List: " + mergedList);

        // 交集
        List<String> intersectionList = (List<String>) CollUtil.intersection(list1, list2);
        System.out.println("Intersection List: " + intersectionList);

        // 差集
        List<String> differenceList = (List<String>) CollUtil.subtract(list1, list2);
        System.out.println("Difference List (list1 - list2): " + differenceList);

        // 判断集合是否包含所有元素
        boolean containsAll = CollUtil.containsAll(list1, list2);
        System.out.println("List1 contains all elements of List2: " + containsAll);

        // 转换集合为 Set
        Set<String> set1 = CollUtil.newHashSet("apple", "banana", "cherry");
        System.out.println("Set1: " + set1);

        // 判断是否为空集合
        boolean isEmpty = CollUtil.isEmpty(list1);
        System.out.println("Is List1 empty? " + isEmpty);
    }
}
